﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using WWLauncher.Util;
namespace WWLauncher.Upgrade
{
    internal class MainWindowViewModel : INotifyPropertyChanged
    {
        private string version = string.Empty;
        private string message = string.Empty;
        private ICommand checkUpdate;
        private int progressBarValue; 
        private string information;
        public MainWindowViewModel()
        {
            
        }
        public string Version
        {
            get
            {
                return version;
            }
            set
            {
                version = value;
                OnPropertyChanged("Version");
            }
        }
        public string Message
        {
            get
            {
                return message;
            }
            set
            {
                message = value;
                OnPropertyChanged("Message");
            }
        }
        public ICommand CheckUpdateCommand
        {
            get
            {
                return checkUpdate ??= new RelayCommand(
                    p => true,
                    p =>
                    {
                        Message = "test;";

                    });
            }
        }
        public int ProgressBarValue
        {
            get
            {
                return progressBarValue;
            }
            set
            {
                progressBarValue = value;
                OnPropertyChanged("ProgressBarValue");
            }
        }

        public int Maximum { get; internal set; }
      

        public string Information
        {
            get => information; set => SetProperty(ref information, value);
        }
        public object PackageUrl { get; internal set; }
        public object PackageVersion { get; internal set; }

        [field: NonSerialized]
        public event PropertyChangedEventHandler PropertyChanged;
        private void OnPropertyChanged(string propertyName)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }

        protected bool SetProperty<T>(ref T field, T newValue, [CallerMemberName] string propertyName = null)
        {
            if (!Equals(field, newValue))
            {
                field = newValue;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
                return true;
            }

            return false;
        }

      
    }
}
